<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>文章资料</title>
        <meta name="search" content="price" />
        <meta name="author" content="chunhai.chen(15317227@qq.com)" />
        <meta name="META_MAIN_MENU_ID" content="ADMIN_ARTICLES" />
        <c:set var="trailLinks" value=""></c:set>
        <c:if test="${not empty currentCategory && not empty primaryCategoryTrail}">
            <c:forEach items="${primaryCategoryTrail}" var="v" varStatus="vst">
            	<c:set var="class" value=""/>
            	<c:if test="${v.uid == currentCategory.uid}"><c:set var="class" value="current"/></c:if>			
                <c:set var="tmp" value="<span class='sep'>› </span><a class='${class}' href='/admin/article/list.htm?guid=${v.uid}'>${v.name}</a>"/>
                <c:set var="trailLinks" value="${trailLinks}${tmp}"></c:set>
            </c:forEach>
        </c:if>
        <meta name="trailLinks" content="${trailLinks}" />
    </head>
    <body>
        <div style="padding:20px;">
           	<form action="/admin/article/list/delete.htm" method="GET" name="delform">
            <table width='100%' id="customerTable" class="yui-grid">
                <thead>
                    <tr>
                        <th colspan="8" align='left'> <p style='font-size: 20px;margin:0'> 
                        <c:if test="${not empty currentCategory}">[<A href="/articles/${currentCategory.uid }.htm" target="_blank">${currentCategory.name }</A>]</c:if>
							文章列表 </p> </th>
                    </tr>
					
					<c:if test="${ not empty childCategories}">
                    <tr>
                        <td colspan="8" align='left'> 
							
							    <ul class="childcategories">
							        <c:forEach items="${childCategories}" var="v" varStatus="vst">
							            <li class="childcategory ">
							                <a href="/admin/article/list.htm?guid=${v.uid}">${v.name}</a>
							            </li>
							        </c:forEach>
							    </ul>
						</td>
                    </tr>
					</c:if>
		            <tr>
		                  <th nowrap>   </th> <th nowrap> 名称 </th>  <th nowrap>作者 </th>  <th nowrap>所属分类 </th>  <th nowrap> 创建时间 </th> <th nowrap> 公开时间 </th>  
		                  <th nowrap>
		                  	<c:if test="${empty childCategories }"><A href="/admin/article/add.htm?pguid=${currentCategory.uid }">新增博文</A> </c:if>
		                  </th>
		            </tr>
				</thead>						
                <tbody>
                	<c:choose>
                		<c:when  test="${not empty articles}">
	                        <c:forEach items="${articles}" var="v" varStatus="vst">
	                            <tr>                                
	                                <td width=1> <input type='checkbox' name='uid' value='${v.uid}'> </td>                               
	                                <td> <A href="/admin/article/edit.asp?uid=${v.uid }">${v.name}</A> </td>
	                                <td width='1px' nowrap> <A href="http://${v.author.blogUrl }">${v.author.name}</A> </td>
	                                <td width='1px' nowrap>
	                                	<c:choose>
	                                		<c:when test="${not empty v.primaryCategory}">
	                                    		<A href="/admin/article/list.htm?guid=${v.primaryCategory.uid }"><c:out value="${v.primaryCategory.name}" default="${v.primaryCategory.uid}"></c:out></A>                                			
	                                		</c:when>
											<c:otherwise>
	                                    		<A href="/admin/article/setprimarycategory.htm?uid=${v.uid }">?设置</A>                                			
											</c:otherwise>
	                                	</c:choose>
	                                </td>
	
	                                <td width='1px' nowrap> 
										 <fmt:formatDate value="${v.created }" pattern ="yyyy-MM-dd HH:mm" />  
									</td>
									
	                                <td width='1px' nowrap>
	                                    <c:choose>
	                                        <c:when test="${v.status == 'ONLINE'}"> <fmt:formatDate value="${v.statusUpdated}"  pattern ="yyyy-MM-dd HH:mm" />  </c:when>
	                                        <c:otherwise>-</c:otherwise>
	                                    </c:choose>
	                                </td>
	                                <td width='1px' nowrap>
	                                    <c:choose>
	                                        <c:when test="${v.status == 'ONLINE'}">
	                                            <A href='/admin/article/unpublish.asp?uid=${v.uid }'>不公开</A>
	                                        </c:when>
	                                        <c:otherwise>
	                                            <A href='/admin/article/publish.asp?uid=${v.uid }'>公开</A>
	                                        </c:otherwise>
	                                    </c:choose>
	                                </td>
	                            </tr>
	                        </c:forEach>
                		</c:when>
                		<c:otherwise>
                			<tr><td colspan="7">没有博文</td></tr>
                		</c:otherwise>
                	</c:choose>
                </tbody>
		        <thead>
		            <tr>
		                  <th> <input type="submit" name="submit" value="删除"/> <th nowrap> 名称 </th>     <th nowrap> 作者 </th> <th nowrap>所属分类 </th>  <th nowrap> 创建时间 </th> <th nowrap> 公开时间 </th>  
		                  <th  nowrap>
		                  	<c:if test="${empty childCategories }"><A href="/admin/article/add.htm?pguid=${currentCategory.uid }">新增博文</A> </c:if>
		                  </th>
		            </tr>
				</thead>	
				<c:if test="${totalItems > pageSize}">
		        <thead>
		            <tr>
		                  <th colspan="7">
							<div id="Pagination" class="pagination"></div>		                  
							
								<c:set var="requester" value="<%=request.getServerName()+ (request.getServerPort()==80 ? "" : ":"+request.getServerPort())%>"/>
								<script type="text/javascript" src="/js/jquery.pagination.js"></script>
						 		<script type="text/javascript">
						            /**
						             * Callback function that displays the content.
						             *
						             * Gets called every time the user clicks on a pagination link.
						             *
						             * @param {int}page_index New Page index
						             * @param {jQuery} jq the container with the pagination links as a jQuery object
						             */
									function pageselectCallback(page_index, jq){
						                // Replace old content with new content
										// $('#Searchresult').html(newcontent);
										// return false;
						                
						                return true;
						            }
						            
						
						            // When document has loaded, initialize pagination and form 
						            $(document).ready(function(){
										<c:choose>
									        <c:when test="${not empty currentCategory}">
												var url="/admin/article/list.htm?guid=${currentCategory.uid}.htm&pageNo=__id__&pageSize=${pageSize}";
											</c:when>
											<c:otherwise>
												var url="/admin/article/list.htm?guid=pageNo=__id__&pageSize=${pageSize}";
											</c:otherwise>
										</c:choose>
						
										var totalItems = "${totalItems}";
						                var optInit = {
														callback: pageselectCallback,
														current_page: "${pageNo}",
														link_to: url,
														items_per_page: "${pageSize}",
														num_display_entries: 8,
														num_edge_entries: 2,
														prev_text: "上一页",
														next_text: "下一页"
													};
						                $("#Pagination").pagination(totalItems, optInit);              
						            });
						            
						        </script>
						  </th>
		            </tr>
				</thead>	
				</c:if>				
            </table>
			</form>					
        </div>
    </body>
</html>
